﻿using System;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace test_score_unit
{
    /// <summary>
    /// Summary description for test_score_unit
    /// </summary>
    [TestClass]
    public class test_score_unit
    {
        Score score;
        int player1score;
        int player2score;
        int tie;
        public test_score_unit()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestInitialize]
        public void testInitialize()
        {
            player1score = 5;
            player2score = 3;
            tie = 2;
            score = new Score(player1score,player2score,tie);
        }

        [TestMethod]
        public void Scores()
        {

            Assert.AreEqual(player1score, score.getPlayer1(), "Player1 score is not equal");
            Assert.AreEqual(player2score, score.getPlayer2(), "Player2 score is not equal");
            Assert.AreEqual(tie, score.getTie(), "Tie score is not equal");
        }

        [TestMethod]
        public void RaiseScores()
        {
            score.increasePlayer1Score();
            score.increasePlayer2Score();
            score.increaseTie();
            player1score++;
            player2score++;
            tie++;

            Assert.AreEqual(player1score, score.getPlayer1(), "Player1 Increace Score does not work");
            Assert.AreEqual(player2score, score.getPlayer2(), "Player2 Increace Score does not work");
            Assert.AreEqual(tie, score.getTie(), "Tie Increace Score does not work");
        }

        [TestMethod]
        public void setScores()
        {
            score.setPlayer1(player1score);
            score.setPlayer2(player2score);
            score.setTie(tie);

            Assert.AreEqual(player1score, score.getPlayer1(), "Player1 Set Score does not work");
            Assert.AreEqual(player2score, score.getPlayer2(), "Player2 Set Score does not work");
            Assert.AreEqual(tie, score.getTie(), "Tie Set Score does not work");
        }

        [TestMethod]
        public void totalGames()
        {
            Assert.AreEqual(player1score + player2score + tie, score.getTotalGamesPlayed(), "Total Games Played does not work");
        }
    }
}
